home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************/
- /* */
- /* YTDeSim.rexx */
- /* Copyright ©1997 by Dick Whiting */
- /* */
- /*----------------------------------------------------------------------------*/
- /* This script requires YAMTOOLS for it to work. If you don't have YAMTOOLS */
- /* you can get it on Aminet in directory comm/mail. This script allows you */
- /* to locate and delete duplicate mail in a YAM folder. */
- /*----------------------------------------------------------------------------*/
- /* */
- /* Logic: This script considers 2 mail to be duplicates IFF: */
- /* 1) From fields are the same, AND */
- /* 2) Subject fields are SIMILAR, AND */
- /* SIMILAR= same subject after last 'anything:' and last '[anything]' */
- /* 3) Date fields are the same */
- /* */
- /* NOTE: There is a REAL possibility that non-duplicates will be incorrectly */
- /* deleted. Could happen if a person mailed 2 or more within the same second */
- /* and used subjects that were the same or similar. */
- /* */
- /* */
- /*----------------------------------------------------------------------------*/
- /* */
- /* Standard Disclaimer: I wrote it, it works for me, I don't guarantee */
- /* that it will do anything productive for anyone else, etc. etc. ;-) */
- /* */
- /*HOWEVER, if you DO find a use for it: I homeschool my kids and they */
- /*would love a postcard from where EVER you live. */
- /* */
- /*Instant GEOGRAPHY lesson;) */
- /* */
- /* */
- /*POSTCARDS: Dick Whiting */
- /* 28590 S. Beavercreek Rd. */
- /* Mulino, Oregon 97042 */
- /* USA */
- /* */
- /*----------------------------------------------------------------------------*/
- /* */
- /* Address Bug Reports or Comments to: */
- /* Dick Whiting <dwhiting@europa.com> */
- /* 15 June 1997 */
- /* */
- /******************************************************************************/
- /*
- $VER: 1.1 Copyright ©1997 by Dick Whiting
- $AUTHOR: Dick Whiting
- $DESCRIPTION: Find and Delete Similar Mail in a YAM folder
- */
-
- options results
- options failat 9999 /* keep maildelete return from showing */
-
- filename=''
- rest=''
-
- parse arg filename rest
-
- /**************************************************************************/
- /* Initialize Variables */
- /**************************************************************************/
- Call MUIvars /* go define vars for MUI use */
- Call YTvars /* various values used in YT */
- Call Helpvars /* pointers into HELP guide */
- Call Localize /* vars for localizing strings*/
- Call Builtvars /* built using previous values*/
-
- /**************************************************************************/
- /* MAIN LOGIC FOR YTDESIM.rexx */
- /**************************************************************************/
- Call CheckYam /* make sure Yam is running */
-
- if filename='' then do
- errmsg=_text._choosefold
- Call ErrorMsg
- end
-
- Call GetMinfo /* get info for all mail in folder*/
- Call FindDups /* sort array & identify dups */
- Call DeleteDups /* go do the deletes */
-
- exit
-
- /**************************************************************************/
- /* Get From and Subject using YAM facilities */
- /* */
- /* minfo array: from subject date mailnumber size */
- /**************************************************************************/
- GetMinfo:
-
- minfo.=missing
- minfo.0=0
-
- Address YAM 'GetFolderInfo Number'
- anum=result
- Address YAM 'GetFolderInfo Max'
- mailcnt=result
- minfo.0=mailcnt
- do i=0 to mailcnt-1
- mnum=i
- j=i+1
- Address YAM 'Setmail' mnum
- Address YAM 'Getmailinfo From'
- mfrom=upper(result)
- Address YAM 'Getmailinfo Subject'
- msubj=result
- Call TrimSubj
- Address YAM 'Getmailinfo File'
- mpath=result
- mdate=missing
- Call GetDate
- mstring=mfrom'|'mdate'|'msubj'|'anum'|'mnum'|'mpath
- minfo.j=mstring
- end
-
- Return
-
- /**************************************************************************/
- /* Trim Subject Line for Compares */
- /**************************************************************************/
- TrimSubj:
-
- newsubj=strip(msubj)
- do wordcnt=1 to words(msubj)
- select
- when right(word(msubj,wordcnt),1)=':' then do
- newsubj=subword(newsubj,2)
- end
- when right(word(msubj,wordcnt),1)=']' &,
- left(word(msubj,wordcnt),1)='[' then do
- newsubj=subword(newsubj,2)
- end
- otherwise leave wordcnt
- end
- end
- msubj=newsubj
-
- Return
-
- /**************************************************************************/
- /* Read mail file for Date: line */
- /**************************************************************************/
- GetDate:
-
- goodopen=open('IN',mpath,'R')
- datefound=FALSE
- if goodopen then do
- do until eof('IN') | datefound
- linein=readln('IN')
- if linein='' then datefound=TRUE
- if word(linein,1)='Date:' then do
- mdate=subword(linein,2)
- mdate=strip(mdate)
- datefound=TRUE
- end
- end
- result=close('IN')
- end
- else do
- errmsg=_text._badmail
- Call ErrorMsg
- exit
- end
-
- Return
-
- /**************************************************************************/
- /* Sort mail info array and locate similar mail */
- /**************************************************************************/
- FindDups:
-
- if show('L','rexxtricks.library') then do /* use tricks library */
- call QSORT(minfo) /* sort by name, line number */
- end
- else do /* use QuickSort format */
- call QSORT(1, minfo.0, minfo) /* sort by name, line number */
- end
-
- dinfo.=missing /* array of duplicates */
- dinfo.0=0
-
- oldfrom=missing /* set break values */
- olddate=missing
- oldsubj=missing
-
- do i=1 to minfo.0
- parse var minfo.i mfrom '|' mdate '|' msubj '|' anum '|' mnum '|' mpath
- if mfrom~=oldfrom | mdate~=olddate | msubj~=oldsubj then do
- oldfrom=mfrom
- olddate=mdate
- oldsubj=msubj
- end
- else do
- j=1+dinfo.0
- dinfo.0=j
- dstring=anum'|'mnum'|'mpath
- dinfo.j=dstring
- end
- end
-
- Return
-
- /**************************************************************************/
- /* Sort Duplicate list, check for list change, do deletes */
- /* Process in reverse list order to keep from changing list order */
- /**************************************************************************/
- DeleteDups:
-
- if dinfo.0=0 then do /* no duplicates found */
- errmsg=_text._nodups
- Call ErrorMsg
- exit
- end
-
- if show('L','rexxtricks.library') then do /* use tricks library */
- call QSORT(dinfo)
- end
- else do /* use QuickSort format */
- call QSORT(1, dinfo.0, dinfo)
- end
-
- do i=dinfo.0 to 1 by -1
- parse var dinfo.i anum '|' mnum '|' mpath
- Address YAM 'Setfolder' anum
- Address YAM 'Setmail' mnum
- Address YAM 'Getmailinfo File'
- testpath=result
- if mpath~=testpath then do
- errmsg=_text._chgfolder
- Call ErrorMsg
- exit
- end
- Address YAM 'maildelete'
- end
-
- errmsg=dinfo.0||_text._maildeleted
- Call ErrorMsg
- exit
-
- Return
-
- /**************************************************************************/
- /* Make sure YAM and YAMTOOLS are running. Show YAM. */
- /**************************************************************************/
- CheckYAM:
-
- if ~show('p','YAMTOOLS') then do
- errmsg=_text._noyt
- say errmsg
- exit
- end
-
- Address YAMTOOLS
-
- if ~show('p','YAM') then do
- errmsg=_text._noyam
- Call ErrorMsg
- exit
- end
-
- Address YAM 'show' /* uniconify YAM's screen */
-
- Address YAM 'info SCREEN' /* get YAM's screen */
- screen=result
- if screen='' then screen='Workbench'
-
- Return
-
- /******************************************************************************/
- /* Display ERROR message and EXIT. */
- /******************************************************************************/
- ErrorMsg:
-
- Address YAMTOOLS
-
- request ID ERRM GADGETS _text._ok errmsg
-
- exit
-
- Return
-
- /******************************************************************************/
- /* MUIREXX TAGS & VARIABLES */
- /******************************************************************************/
- Muivars:
-
- TRUE=1
- FALSE=0
-
- Return
- /**************************************************************************/
- /* Various values used throughout the various routines */
- /**************************************************************************/
- YTvars:
-
- missing='.'
-
- Return
-
- /**************************************************************************/
- /* Messages, text, etc. constructed using previously defined values */
- /**************************************************************************/
- Builtvars:
-
- Return
-
- /**************************************************************************/
- /* Pointers into the YamTools.guide documentation */
- /**************************************************************************/
- Helpvars:
-
- node.SQUIT='7.3.'
- node.STEXT='7.3.'
-
- Return
-
- /**************************************************************************/
- /* Mui Gadgets, text, msgs, etc. used in YamTools */
- /**************************************************************************/
- Localize:
-
- /*********************************/
- /* Miscellaneous info strings */
- /*********************************/
-
- _text._ok="Ok" /* various OK buttons */
-
- /*********************************/
- /* Various error conditions */
- /*********************************/
-
- _text._noyam="You need YAM running to use YTDeSim" /* yam not running */
- _text._noyt="You need YAMTOOLS running to use YTDeSim" /* no yamtools */
- _text._chgfolder="Folder order has changed--quitting this folder"
- _text._maildeleted=" mail(s) in folder deleted"
- _text._nodups="No Duplicates Found in Folder"
- _text._badmail="Unable to open a mailfile--exiting"
- _text._choosefold="Choose Folder for Locating Similar Mail"
-
-
- /**************************************************************************/
- /* Help Messages to display with MUI bubble facility. */
- /* */
- /* Format is simple: help.ID where ID is the id specified on the MUI */
- /* object statement. */
- /* Similar approach for accessing the .guide information using the NODE */
- /* option on the object statement. */
- /* */
- /**************************************************************************/
-
- help.SQUIT=""""""
- help.STEXT=""""""
-
- Return
-
-
-
-